$(document).ready(function () {
	ybnsrcx.onLoad();
})

var ybnsrcx = (function () {
	var init = function () {
		//私有属性
		var curSeg;
		layui.use('form', function () {
			var form = layui.form
		});
	}
	return {
		onLoad: function () {
			init();
		},
		/*查询*/
		onQuery: function () {
			var nsrsbh = $(".wxl_jnsrsbh").val().trim();
			if (nsrsbh != "") {
				$.ajax({
					url: "http://bsfwt.ha-n-tax.gov.cn/bsfwt/sscx/getBSFW_SSCX.do",
					type: "GET",
					data: {
						CXLB: "YBNSRZGCX",
						NSRSBH: nsrsbh,
						NSRMC: ""
					},
					dataType: "jsonp",
					jsonpCallback: "ybnsrcx.onqueryCallback",
				});
			} else {
				layer.msg('纳税人识别号不能为空');
			}
		},
		onqueryCallback: function (jsonObj) {
            if(jsonObj.data==""){
            	layer.msg('我局查询不到该企业信息，请确认信息输入是否正确。');
            }else{
            	if ( $.fn.dataTable.isDataTable( '#wxlYbnsrcx' ) ) {
            		var table = $('#wxlYbnsrcx').DataTable();
            		table.destroy();
            	}
            	$('#wxlYbnsrcx').DataTable({
            		"data": jsonObj.data,
            		"columns": [{
            				"data": "NSRSBH"
            			},
            			{
            				"data": "SHXYDM"
            			},
            			{
            				"data": "NSRMC"
            			},
            			{
            				"data": "ISORNO",
            				"render":function(data){
            					console.log(data)
            					switch(data){
            						case "Yes":
            							return "是";
            							break;
            						case "No":
            							return "否";
            							break;
            						default:
            					}
            				}
            			},
            			{
            				"data": "YXQ_Q"
            			},
            			{
            				"data": "YXQ_Z"
            			},
            			{
            				"data": "SWJG_MC"
            			},
            		],
            		"ordering": false,
            		"info": false,
            		"lengthChange": false,
            		"searching": false
            	})
            }
		},
		winReset: function () {
			var nsrsbh = $(".wxl_jnsrsbh").val("");
			$("#wxlYbnsrcx tbody").empty()
		},
		

	}
})();
